package com.zw.mizhe.view.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;

import com.zw.mizhe.R;
import com.zw.mizhe.api.ExceptionHandle;
import com.zw.mizhe.bean.temai.HomeEntity;
import com.zw.mizhe.common.base.mvp.MvpLazyFragment;
import com.zw.mizhe.presenter.HomePresenter;
import com.zw.mizhe.view.impl.HomeFragmentView;

import butterknife.BindView;

/**
 * Created by zhangwei on 16/10/22.
 */

public class HomeChildFragment extends MvpLazyFragment<HomeFragmentView, HomePresenter> implements HomeFragmentView {

    private static final String PARAMS_ARGS_REQUEST_PATH = "path";
    private static final String PARAMS_ARGS_REQUEST_TYPE = "type";
    @BindView(R.id.home_recycler_view)
    RecyclerView homeRecyclerView;

    private String requestPath;
    private String requestType;
    private int page;

    public static HomeChildFragment newInstance(String path, String type) {
        Bundle args = new Bundle();
        args.putString(PARAMS_ARGS_REQUEST_PATH, path);
        args.putString(PARAMS_ARGS_REQUEST_TYPE, type);
        HomeChildFragment fragment = new HomeChildFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void before() {
        if (getArguments() != null) {
            requestPath = getArguments().getString(PARAMS_ARGS_REQUEST_PATH);
            requestType = getArguments().getString(PARAMS_ARGS_REQUEST_TYPE);
        }
    }

    @NonNull
    @Override
    public HomePresenter createPresenter() {
        return new HomePresenter();
    }

    @Override
    public void onFail(ExceptionHandle.ResponeThrowable e) {

    }

    @Override
    public void onFinish() {

    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {
        mPresenter.getData(page, requestType, requestPath);
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_home_child;
    }


    @Override
    public void onSuccess(HomeEntity entity) {
        System.out.println(entity.toString());
    }
}
